import { ColorConfig } from "../../resource/ColorConfig";
import { ECamp } from "../../../../Message/Public/ECamp";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { MuiEvent } from "../../../../com/mui/events/MuiEvent";
import { GTextBar } from "./GTextBar";
import { GBoxDirection } from "../../../../com/mui/containers/globalVariable/GBoxDirection";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { ECareer } from "../../../../Message/Public/ECareer";
import { _campOneColor } from "../../../../this/_campOneColor";
import { _campTwoColor } from "../../../../this/_campTwoColor";
import { _campThreeColor } from "../../../../this/_campThreeColor";
type int = number;
//class RankSelectedPanel
    
    export  class RankSelectedPanel /* flash.display.Sprite */
    {
        constructor()
        {
            this._campOneColor = ColorConfig.instance.getCountryColor(ECamp._ECampOne).intColor;
            this._campTwoColor = ColorConfig.instance.getCountryColor(ECamp._ECampTwo).intColor;
            this._campThreeColor = ColorConfig.instance.getCountryColor(ECamp._ECampThree).intColor;
            this._campBarDp = [{"color": 15859633, "text": Language.getString(32052)}, {"color": _campOneColor, "text": Language.getString(32053)}, {"color": _campTwoColor, "text": Language.getString(32054)}, {"color": _campThreeColor, "text": Language.getString(32055)}];
            this._careerBarDp = [{"color": 15859633, "text": Language.getString(32052)}, {"color": 11661311, "text": Language.getString(31023)}, {"color": 11661311, "text": Language.getString(31024)}, {"color": 11661311, "text": Language.getString(31025)}, {"color": 11661311, "text": Language.getString(31026)}, {"color": 11661311, "text": Language.getString(31069)}, {"color": 11661311, "text": Language.getString(31070)}, {"color": 11661311, "text": Language.getString(31071)}, {"color": 11661311, "text": Language.getString(31072)}];
            this._sexBarDp = [{"color": 15859633, "text": Language.getString(32052)}, {"color": 11661311, "text": Language.getString(32056)}, {"color": 11661311, "text": Language.getString(32057)}];
            
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=ObjCreate.createGTextField(Language.getString(30007), 0, 2, 35, 20, this, GlobalStyle.textFormat1);
            this._career = ObjCreate.createGTextField(Language.getString(30006), 0, 22, 35, 20, this, GlobalStyle.textFormat1);
            this._sex = ObjCreate.createGTextField(Language.getString(30010), 300, 2, 35, 20, this, GlobalStyle.textFormat1);
            this._campBar = this.createTextBar(35, 0, this._campBarDp);
            this._campBar.addEventListener(MuiEvent.GTABBAR_SELECTED_CHANGE, this.onCampSelectedHandler);
            this._careerBar = this.createTextBar(35, 20, this._careerBarDp);
            this._careerBar.addEventListener(MuiEvent.GTABBAR_SELECTED_CHANGE, this.onCareerSelectedHandler);
            this._sexBar = this.createTextBar(335, 0, this._sexBarDp);
            this._sexBar.addEventListener(MuiEvent.GTABBAR_SELECTED_CHANGE, this.onSexSelectedHandler);
            return;
        }

        /* internal  */createTextBar(arg1: int, arg2: int, arg3: Array<any>): GTextBar
        {
            var loc1;
            (loc1 = new GTextBar()).textWidth = 40;
            loc1.verticalGap = 3;
            loc1.x = arg1;
            loc1.y = arg2;
            loc1.direction = GBoxDirection.HORIZONTAL;
            loc1.dataProvider = arg3;
            loc1.selectedIndex = 0;
            addChild(loc1);
            return loc1;
        }

        /* internal  */onCampSelectedHandler(arg1: MuiEvent): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.RankingCampChange, this._campBar.selectedIndex));
            return;
        }

        /* internal  */onCareerSelectedHandler(arg1: MuiEvent): void
        {
            var loc1=-1;
            var loc2=this._careerBar.selectedIndex;
            switch (loc2) 
            {
                case 0:
                {
                    loc1 = -1;
                    break;
                }
                case 1:
                {
                    loc1 = ECareer._ECareerWarrior;
                    break;
                }
                case 2:
                {
                    loc1 = ECareer._ECareerArcher;
                    break;
                }
                case 3:
                {
                    loc1 = ECareer._ECareerFireMage;
                    break;
                }
                case 4:
                {
                    loc1 = ECareer._ECareerDoctor;
                    break;
                }
                case 5:
                {
                    loc1 = ECareer._ECareerWarriorD;
                    break;
                }
                case 6:
                {
                    loc1 = ECareer._ECareerStabber;
                    break;
                }
                case 7:
                {
                    loc1 = ECareer._ECareerIceMage;
                    break;
                }
                case 8:
                {
                    loc1 = ECareer._ECareerPriest;
                    break;
                }
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.RankingCareerChange, loc1));
            return;
        }

        /* internal  */onSexSelectedHandler(arg1: MuiEvent): void
        {
            var loc1=-1;
            var loc2=this._sexBar.selectedIndex;
            switch (loc2) 
            {
                case 0:
                {
                    loc1 = -1;
                    break;
                }
                case 1:
                {
                    loc1 = 0;
                    break;
                }
                case 2:
                {
                    loc1 = 1;
                    break;
                }
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.RankingSexChange, loc1));
            return;
        }

        public showOrHideSexBar(arg1: Boolean): void
        {
            this._sex.visible = arg1;
            this._sexBar.visible = arg1;
            return;
        }

        public showOrHideCareerBar(arg1: Boolean): void
        {
            this._career.visible = arg1;
            this._careerBar.visible = arg1;
            return;
        }

        public resetBar(): void
        {
            this._campBar.selectedIndex = 0;
            this._sexBar.selectedIndex = 0;
            this._careerBar.selectedIndex = 0;
            return;
        }

        /* internal */ /* var */_career: Object /* flash.text.TextField */;

        /* internal */ /* var */_sex: Object /* flash.text.TextField */;

        /* internal */ /* var */_campBar: GTextBar;

        /* internal */ /* var */_careerBar: GTextBar;

        /* internal */ /* var */_sexBar: GTextBar;

        /* internal */ /* var */_campOneColor: uint;

        /* internal */ /* var */_campTwoColor: uint;

        /* internal */ /* var */_campThreeColor: uint;

        /* internal */ /* var */_campBarDp: Array<any>;

        /* internal */ /* var */_careerBarDp: Array<any>;

        /* internal */ /* var */_sexBarDp: Array<any>;
    }
